package com.warm.pump.module.monitor.controller;

import com.warm.pump.frame.gen.bean.PageBean;
import com.warm.pump.frame.gen.util.OutJson;
import com.warm.pump.module.monitor.bean.po.gen.LogMailHis;
import com.warm.pump.module.monitor.service.ILogMailHisService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;


/**
 *  sys_log_mail_his
 *
 */
@Controller
@RequestMapping("/logMailHis")
public class LogMailHisController {
	@Autowired
	private ILogMailHisService logMailHisService;

	
	/**
	 * 列表
	 */
	@ResponseBody
	@RequestMapping("/list")
	@RequiresPermissions("logMailHis:list")
	public OutJson list(Integer page, Integer limit){
		Map<String, Object> map = new HashMap<>();
        map.put("orderBy","send_time desc");
       //查询列表数据
        PageBean pageBean = logMailHisService.getPageBeanByMap(map, page, limit);

		return OutJson.ok().put("page", pageBean);
	}


	/**
	 * 信息
	 */
	@ResponseBody
	@RequestMapping("/info/{oid}")
	@RequiresPermissions("logMailHis:info")
	public OutJson info(@PathVariable("oid") Long  oid){
		LogMailHis logMailHis = logMailHisService.queryObject(oid);
		
		return OutJson.ok().put("logMailHis", logMailHis);
	}


	/**
	 * 保存
	 */
	@ResponseBody
	@RequestMapping("/save")
	@RequiresPermissions("logMailHis:save")
	public OutJson save(@RequestBody LogMailHis logMailHis){
		logMailHisService.save(logMailHis);
		
		return OutJson.ok();
	}
	
	/**
	 * 修改
	 */
	@ResponseBody
	@RequestMapping("/update")
	@RequiresPermissions("logMailHis:update")
	public OutJson update(@RequestBody LogMailHis logMailHis){
		logMailHisService.update(logMailHis);
		
		return OutJson.ok();
	}
	
	/**
	 * 删除
	 */
	@ResponseBody
	@RequestMapping("/delete")
	@RequiresPermissions("logMailHis:delete")
	public OutJson delete(@RequestBody Long [] oids){
		logMailHisService.deleteBatch(oids);
		
		return OutJson.ok();
	}
	
}
